#!/bin/sh
# 1. pull docker images we need
workdir=$PWD
echo "current work dirctory: $workdir"

echo 'pull images begin...'

image_array=("nginx:latest" "php:7.4-fpm" "mysql:8.0" "redis:latest")
for image in ${image_array[@]};
do
	docker images | grep -E ${image/:/\.\*} &> /dev/null
    if [ $? -ne 0 ]
    then
        echo "pull $image image begin..."
        docker pull $image
        echo "pull $image image done"
    else
        echo "$image image is existed!!!"
    fi
done

echo 'pull images done'

# create network bridge
docker network ls | grep lnmp &> /dev/null
if [ $? -ne 0 ]
then
    echo "network lnmp create begin..."
    docker network create lnmp
    echo "network lnmp create done"
else
    echo "network lnmp is existed!!!"
fi
